package com.csaba.db.views;

import org.eclipse.core.resources.IProject;
import org.eclipse.jface.resource.ImageDescriptor;

import com.csaba.db.Activator;

public class UserDB implements IUserDBTreeParent
{

	private final IProject project;

	public UserDB( final IProject project )
	{
		super();
		this.project = project;
	}

	public String getName()
	{
		return project.getName();
	}

	public boolean isOpen()
	{
		return project.isOpen();
	}

	@Override
	public Object[] getChildren()
	{
		if ( !project.isOpen() )
			return null;

		//TODO implement extension point here for DBConsumers to provide content for DB
		return null;
	}

	@Override
	public Object getParent()
	{
		//there is no parent for user DB-s in the tree
		return null;
	}

	@Override
	public boolean hasChildren()
	{
		if ( !project.isOpen() )
			return false;
		//TODO implement extension point here for DBConsumers to provide content for DB
		return false;
	}

	@Override
	public ImageDescriptor getImageDescriptor()
	{
		ImageDescriptor image = null;
		if ( project.isOpen() )
		{
			image = Activator.getDefault().getImageDescriptor(Activator.IMG_OPEN_DB);
		}
		else
		{
			image = Activator.getDefault().getImageDescriptor(Activator.IMG_CLOSED_DB);
		}

		return image;
	}

}
